package com.nb.protocol.util;

import com.nb.protocol.db.DbCtrl;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

/**
 * @function:
 * @author: hjw
 * @date: 2018/1/9
 * @company: Sinoregal
 * @copyright: 2018 www.sinoregal.cn. All rights reserved.
 */
public class PropertyUtil {
    InputStream inputStream = null;
    Properties p = null;

    private static final PropertyUtil INSTANCE = new PropertyUtil();

    public static PropertyUtil getInstance() {
        return INSTANCE;
    }

    private PropertyUtil() {
        try {
            p = new Properties();
            p.load(PropertyUtil.class.getClassLoader().getResourceAsStream("config.properties"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public String getProperty(String name) {
        return p.getProperty(name, "").trim();
    }

    public String getProperty(String name, String def) {
        return p.getProperty(name, def).trim();
    }
}
